package book;

class BuyChickenSolution {
    void buyChicken() {
        int count = 0, rooster, hen, chick;
        for (rooster = 0; rooster <= 100; rooster++)
            for (hen = 0; hen <= 100; hen++) {
                chick = 100 - rooster - hen;
                if (chick >= 0 && chick % 3 == 0) {
                    if (5 * rooster + 3 * hen + 1 * chick / 3 == 100) {
                        count++;
                        System.out.printf("解%d: 公鸡%d只 母鸡 %d只 小鸡%d只\n",
                            count, rooster, hen, chick);
                    }
                }
            }
        System.out.println("总共有" + count + "个问题解");
    }
    public static void main(String[] args) {
        new BuyChickenSolution().buyChicken();
    }
}


